/**
 * Created by lenovo on 2017/5/9.
 */
import React from 'react';

import StoreStars from './storeStars.react';
import zanUrl from '../img/imgBrandPage/zan.png';
import chatUrl from '../img/imgBrandPage/chat.png';

class EvaluateSpecialItem extends React.Component{
    constructor(props){
        super(props);

        this.handleZan = this.handleZan.bind(this);
        this.handleChat = this.handleChat.bind(this);

        this.state = {
            specialItem:{
                numOfStars:0,
                item_score:0,
                env_score: 0,
                svr_score: 0
            }
        }
    }


    componentDidMount(){
        let specialItem = this.props.specialItem;
        // if(specialItem.item_score <0 || specialItem.item_score>5){
        //     specialItem.item_score=0;
        // }
        // if(specialItem.env_score <0 || specialItem.env_score>5){
        //     specialItem.env_score=0;
        // }
        // if(specialItem.svr_score <0 || specialItem.svr_score>5){
        //     specialItem.svr_score=0;
        // }
        this.setState({
            specialItem:{
                numOfStars: specialItem.numOfStars,
                item_score: specialItem.item_score,
                env_score: specialItem.env_score,
                svr_score: specialItem.svr_score
            }
        })
    }

    componentWillReceiveProps(nextProps){
        const specialItem = nextProps.specialItem;
        // if(specialItem.item_score <0 || specialItem.item_score>5){
        //     specialItem.item_score=0;
        // }
        // if(specialItem.env_score <0 || specialItem.env_score>5){
        //     specialItem.env_score=0;
        // }
        // if(specialItem.svr_score <0 || specialItem.svr_score>5){
        //     specialItem.svr_score=0;
        // }
        this.setState({
            specialItem:{
                numOfStars: specialItem.numOfStars,
                item_score: specialItem.item_score,
                env_score: specialItem.env_score,
                svr_score: specialItem.svr_score
            }
        })
    }
    handleZan(){

    }

    handleChat(){

    }

    render(){


        return(
            <div className="specialItemContainer">
                <div className="specialItemLine1">
                    <StoreStars numOfStars={this.state.specialItem.numOfStars} />
                    {/*消费金额未知*/}
                    {/*<span className="specialItemFont specialItemCost">消费: ￥553</span>*/}
                </div>
                <div className="specialItemLine2">
                    <span className="specialItemFont">商品: {this.state.specialItem.item_score};</span>
                    <span className="specialItemFont specialItemSpace">环境: {this.state.specialItem.env_score};</span>
                    <span className="specialItemFont specialItemSpace">服务: {this.state.specialItem.svr_score}</span>
                </div>
                <div className="evaluateLine"></div>
                <div className="specialItemLine3">
                    <img className="evaluateBtnL" onClick={this.handleZan} src={zanUrl} />
                    <img className="evaluateBtnL chatBtn" onClick={this.handleChat} src={chatUrl} />
                </div>
            </div>
        )
    }
}

export default EvaluateSpecialItem;